package com.puppyrescue;
import org.apache.commons.lang3.*;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.Date;

import android.graphics.Bitmap;
import android.util.Base64;

public class Segnalazione {
	

	
	private Bitmap foto;
	private File photo;
	private String photoPath;
	private boolean hasPhoto;

	private Date date_hour = new Date();
	
	private String latitude;
	private String longitude;
	private String place;
	private String city;
	private String note;
	private ByteBuffer noteUTF;
	private String telephone;
	private String species;
	private String breed;
	private String color;
	private String size;
	
	private boolean isAggressive;
	private boolean isWounded;
	private boolean isAtRisk;
	private boolean hasCollar;
	
	public Segnalazione(){
		
		foto 		= null;
		hasPhoto 	= false;
		telephone 	= "";
		city 		= "";
		place 		= "";
		latitude	= "";
		longitude	= "";
		note		= "";
		species 		= "";
		breed	= "";
		color	= "";
		size		= "";
	}
	
	
	public boolean isAggressive() {
		return isAggressive;
	}

	public void setAggressive(boolean isAggressive) {
		this.isAggressive = isAggressive;
	}
	public boolean isWounded() {
		return isWounded;
	}
	public void setWounded(boolean isWounded) {
		this.isWounded = isWounded;
	}

	public boolean isAtRisk() {
		return isAtRisk;
	}

	public void setAtRisk(boolean isAtRisk) {
		this.isAtRisk = isAtRisk;
	}

	public boolean hasCollar() {
		return hasCollar;
	}
	public void setCollar(boolean hasCollar) {
		this.hasCollar = hasCollar;
	}
	
	public String getNote(){
		return note;
	}
	
	public void setNote(String note){
		this.note=note;
	}
	
	public String getTelephone() {
		return telephone;
	}


	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}
	
	
	
	public String getSpecies(){
		return species;
	}
	
	public void setSpecies(String species){
		this.species=species;
	}
	
	public String getBreed() {
		return breed;
	}


	public void setBreed(String breed) {
		this.breed = breed;
	}
	public String getColor(){
		return color;
	}
	
	public void setColor(String color){
		this.color=color;
	}
	
	public String getSize() {
		return size;
	}


	public void setSize(String size) {
		this.size = size;
	}
	
	public boolean hasPhoto() {
		
		return hasPhoto;
	}

	public String getPhotoPath() {
		return photoPath;
	}

	public void setPhotoPath(String photoPath) {
		this.photoPath = photoPath;
	}
	public byte[] getFoto(){
		
		ByteArrayOutputStream baos = new ByteArrayOutputStream();  
        foto.compress(Bitmap.CompressFormat.JPEG, 50, baos);
        byte[] b = baos.toByteArray();
		
		return b;
	}
	public String getPhoto(){
		String encodedImage = Base64.encodeToString(getFoto(), Base64.DEFAULT);
		return encodedImage;
	}
	public File getPhotoFile()
	{
		return photo;
	}
	public void setPhotoFile(File ph){
		this.photo = ph;
	}
	public void setFoto(Bitmap temp){
		this.foto=temp;
		this.hasPhoto = true;
	}
	

	public String getDateHour() {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		return sdf.format(date_hour);
		
	}

	public void setDateHour(Date data_ora) {
		this.date_hour = data_ora;
	}
	
	public String getLatitude(){
		return latitude;
	}
	
	public void setLatitude(double lat){
		this.latitude=Double.toString(lat);
	}
	
	public String getLongitude(){
		return longitude;
	}
	
	public void setLongitude(double lon){
		this.longitude=Double.toString(lon);;
	}
	
	public void setPlace(String temp){
		this.place = temp;
	}
	
	public String getPlace(){
		return place;
	}
	public void setCity(String temp){
		this.city = temp;
	}
	
	public String getCity(){
		return city;
	}

	public String getNoteUTF()
	{
		//return new String( (Charset.forName("UTF-8").encode(note)).array(), Charset.forName("UTF-8") );
		return StringUtils.stripAccents(note);
	}
}